{% extends 'basic.html' %}
{% block title %}执行任务{% endblock %}
{% block content %}
    <ul class="nav nav-tabs">
        <li class="active">
            <a href="#server" data-toggle="tab">主机</a>
        </li>
        <li><a href="#servers" data-toggle="tab">主机组</a></li>
    </ul>
    <form action="{% url 'tasks' %}" method="post">
        {% csrf_token %}
        <div class="tab-content" style="padding: 5px 0">
            <div class="tab-pane active fade in" id="server">
                <select name="ip" class="form-control">
                    <option value="">无</option>
                    {% for host in hosts %}
                        <option value="{{ host.ip_addr }}">
                            {{ host.hostname }}:{{ host.ip_addr }}
                        </option>
                    {% endfor %}
                </select>
            </div>
            <div class="tab-pane fade" id="servers">
                <select name="hostgroup" class="form-control">
                    <option value="">无</option>
                    {% for group in groups %}
                        <option value="{{ group.groupname }}">
                            {{ group.groupname }}
                        </option>
                    {% endfor %}

                </select>
            </div>
        </div>
        <table class="table table-bordered table-hover table-striped">
            <thead class="bg-primary">
                <tr>
                    <th>模块</th>
                    <th>参数</th>
                </tr>
            </thead>
            <tbody>
                {% for module in modules %}
                    <tr>
                        <td>
                            <label>
                                <input type="radio" name="module" value="{{ module.modulename }}">
                                {{ module.modulename }}
                            </label>
                        </td>
                        <td>
                            {% for arg in module.argument_set.all %}
                                <div class="radio">
                                    <label>
                                        <input type="radio" name="param" value="{{ arg.arg_text }}">
                                        {{ arg.arg_text }}
                                    </label>
                                </div>
                            {% endfor %}
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
        <div class="form-group text-center">
            <input class="btn btn-primary" type="submit" value="执 行">
            <input class="btn btn-primary" type="reset" value="重 置">
        </div>
    </form>
{% endblock %}